/**
 * Copyright 2018 orivil.com. All rights reserved.
 * Use of this source code is governed by a MIT-style
 * license that can be found at https://mit-license.org.
 */

package main

import (
	"gitee.com/tugoer/orivil/task"
	"time"
	"fmt"
)

func main() {
	container, expiredArgs := task.NewExpireContainer(3 * time.Second)
	done := make(chan struct{})
	go func() {
		for args := range expiredArgs {
			if args == nil {
				done <- struct{}{}
				return
			} else {
				fmt.Println(args)
			}
		}
	}()
	container.Add("key1", 1)
	container.Add("key2", 2)
	container.Add("key3", 3)
	container.Add("key4", 4)
	container.Add("key1", 5)
	container.Add("key2", 6)
	container.Delete("key1")
	time.Sleep(15 * time.Second)
	container.Close()
	<- done
}